import {mapGetters} from "vuex"

export default{
	computed:{
		...mapGetters("m_cart",['total'])
	},
	methods:{
		setBage(){
			uni.setTabBarBadge({
				index:2,
				text:this.total?this.total+'':null
			})
		}
	},
	onShow(){
		this.setBage()
	},
	watch:{
		total:{
			handler(newValue){
				if(newValue){
					uni.setTabBarBadge({
						index:2,
						text:newValue+""
					})
				}else{
					uni.removeTabBarBadge({
						index:2,
					})
				}
				
			},
			immediate:true
		}
		
	}
}